"""gogocup URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from rest_framework import routers
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.documentation import include_docs_urls
from area.views import AreaViewSet
from competition.views import CompetitionViewSet
from gogocup import settings
from group.views import GroupViewSet
from school.views import SchoolViewSet
from student.views import StudentViewSet
from user.views import UserViewSet
from django.views.generic import TemplateView, RedirectView
from django.conf.urls import url, include
from django.views import static



router = routers.DefaultRouter()
router.register(r'user', UserViewSet, base_name="user")  # 用户
router.register(r'area', AreaViewSet, base_name="area")  # 分组

router.register(r'school', SchoolViewSet, base_name="school")  # 用户
router.register(r'student', StudentViewSet, base_name="student")  # 学员
router.register(r'competition', CompetitionViewSet, base_name="competition")  # 学员
router.register(r'group', GroupViewSet, base_name="group")  # 分组





urlpatterns = [
    path('admin/', admin.site.urls),
    path('api-auth/', include('rest_framework.urls')),
    path('api/', include(router.urls)),
    path('api/login/', obtain_jwt_token),  # jwt的token验证
    path('docs/', include_docs_urls(title="gogocup后台管理")),
    url(r'^$', TemplateView.as_view(template_name="index.html")),
    url(r'^static/(?P<path>.*)$', static.serve, {'document_root': settings.STATIC_ROOT}, name='static'),
    url(r'^favicon.ico$', RedirectView.as_view(url=r'static/favicon.ico')),

]
